package flc.ast;

import android.graphics.Color;
import android.view.View;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.ScreenUtils;

import java.util.ArrayList;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.CaricatureFragment;
import flc.ast.fragment.DrawFragment;
import flc.ast.fragment.HomeFragment;
import flc.ast.fragment.TutorialsFragment;
import stark.common.basic.base.BaseNoModelActivity;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.base.DefExitAppDialog;
import stark.common.basic.event.EventStatConstant;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.event.IEventStat;
import stark.common.basic.view.container.StkEventContainer;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> implements View.OnClickListener {

    @Override
    protected int getPageType() {
        return EventStatConstant.PAGE_TAB_HOME;
    }

    @Override
    protected void initView() {
        super.initView();
        EventStatProxy.getInstance().statLaunch(this);
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment=new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class,R.id.llHome));
        listFragment.add(new FragmentViewBinder(DrawFragment.class,R.id.llDraw));
        listFragment.add(new FragmentViewBinder(TutorialsFragment.class,R.id.llTutorials));
        listFragment.add(new FragmentViewBinder(CaricatureFragment.class,R.id.llCaricature));
        return listFragment;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        switch (view.getId()){
            case R.id.llHome:
                mDataBinding.ivHome.setImageResource(R.drawable.shouye1);
                mDataBinding.tvHome.setTextColor(Color.parseColor("#FFFFFF"));
                break;
            case R.id.llDraw:
                mDataBinding.ivDraw.setImageResource(R.drawable.huaban1);
                mDataBinding.tvDraw.setTextColor(Color.parseColor("#FFFFFF"));
                break;
            case R.id.llTutorials:
                mDataBinding.ivTutorials.setImageResource(R.drawable.jiaocheng1);
                mDataBinding.tvTutorials.setTextColor(Color.parseColor("#FFFFFF"));
                break;
            case R.id.llCaricature:
                mDataBinding.ivCaricature.setImageResource(R.drawable.manhua1);
                mDataBinding.tvCaricature.setTextColor(Color.parseColor("#FFFFFF"));
                break;
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection() {
        mDataBinding.ivHome.setImageResource(R.drawable.shouye2);
        mDataBinding.tvHome.setTextColor(Color.parseColor("#5CFFFFFF"));
        mDataBinding.ivDraw.setImageResource(R.drawable.huaban2);
        mDataBinding.tvDraw.setTextColor(Color.parseColor("#5CFFFFFF"));
        mDataBinding.ivTutorials.setImageResource(R.drawable.jiaocheng2);
        mDataBinding.tvTutorials.setTextColor(Color.parseColor("#5CFFFFFF"));
        mDataBinding.ivCaricature.setImageResource(R.drawable.manhua2);
        mDataBinding.tvCaricature.setTextColor(Color.parseColor("#5CFFFFFF"));
    }

}